{% load static %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_language_info for LANGUAGE_CODE as LANG %}
{% get_available_languages as LANGUAGES %}
<nav class="navbar navbar-expand-lg navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="{% url 'site_index' %}">
          <img id="logo" src="{% static 'image/111_write.png' %}" alt="brand">
      </a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav navbar-right self_ul">
            <li><a href="{% url 'site_index' %}">{% trans 'Index' %}<span class="sr-only">(current)</span></a></li>
            <li><a href="{% url 'search:search' %}">{% trans 'Search' %}</a></li>
            <li><a href="{% url 'mlplatform:index' %}">{% trans 'Machine Learning' %}</a></li>
            <li><a href="{% url 'material:all_materials' %}">{% trans 'Tools' %}</a></li>
            <li><a href="{% url 'imagerecognize:image' %}">{% trans 'ImageRecognize' %}</a></li>
            <li><a href="{% url 'accounts:about' %}">{% trans 'About' %}</a></li>
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ LANG.name_local }}<span class="caret"></span></a>
                <ul class="dropdown-menu">
                    {% for lang in LANGUAGES %}
{#                    <li><a href="#">{% trans 'Chinese' %}</a></li>#}
{#                    <li role="separator" class="divider"></li>#}
{#                     <li><a href="#">{% trans 'English' %}</a></li>#}
                        <li>
                            {% get_language_info for lang.0 as cur_lang %}
{#                <a href="{% url 'site_set_language' %}?lang={{ lang.0 }}&next={{ request.path }}">{{ lang.1 }}</a>#}
                            <a href="{% url 'site_set_language' %}?lang={{ cur_lang.code }}&next={{ request.get_full_path|urlencode }}">{{ cur_lang.name_local }}</a>
                        </li>
                    {% endfor %}
                </ul>
            </li>

            {% if request.user.is_authenticated %}
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ request.user.username }}{% trans "'s Home" %} <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><a href="{% url 'accounts:info' %}">{% trans 'My Infomation' %}</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="{% url 'storage:my_template' %}">{% trans 'My Scources' %}</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="{% url 'accounts:notifications' %}">{% trans 'My Notifications' %}</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="javascript:void(0)" onclick="logout()">{% trans 'Logout' %}</a></li>
                </ul>
            </li>
            <li><a href="{% url 'accounts:notifications' %}" title="{% trans 'Notifications' %}"><i class="fa fa-bell" aria-hidden="true"></i></a></li>
            {% else %}
                <li><a href="{% url 'accounts:login' %}">{% trans 'Login' %}</a></li>
            {% endif %}
        </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>